"""
@Author : 合肥一元数智教育科技有限公司
@Date :  2025/3/6 9:42
@Description :  将字典格式的数据准换位json写出到文件

"""
import json

student_dict = {
    'id': 1,
    'student_name': '张三',
    'score': 90
}

# 将字典类型数据写出到文件
"""
with open('dir01/student.json', 'w') as f:
    json_dict = json.dumps(student_dict)
    f.write(json_dict)
"""

# 读取json格式的数据
with open('dir01/student.json', 'r') as f:
    str_student_dict = f.read()
    print(str_student_dict,type(str_student_dict))
    dict_student = json.loads(str_student_dict)
    print(dict_student, type(dict_student))